DEBUG = yes
CC = gcc
RACINE = ../..
LIBPATH = -L $(RACINE)/lib/
LIB = $(RACINE)/lib/libthread.a
BIN = $(RACINE)/bin/application/
EXEC = $(BIN)somme $(BIN)tri $(BIN)fibonacci

ifeq ($(DEBUG),yes)
	CFLAGS = -W -Wall -g
else
	CFLAGS = 
endif

LDFLAGS = -lpthread
LDFLAGSTH = $(LIBPATH) -lthread 

all: $(EXEC)

ifeq ($(DEBUG),yes)
	@echo "Génération en mode debug"
else
	@echo "Génération en mode release"
endif

$(BIN)somme: somme.c $(LIB)
	$(CC) -o $@ $< $(LDFLAGSTH) $(LDFLAGS) $(CFLAGS)
$(BIN)tri: tri.c $(LIB)
	$(CC) -o $@ $< $(LDFLAGSTH) $(LDFLAGS) $(CFLAGS)
$(BIN)fibonacci: fibonacci.c $(LIB)
	$(CC) -o $@ $< $(LDFLAGSTH) $(CFLAGS)

somme: $(BIN)somme
	./$<
tri: $(BIN)tri
	./$<
fibonacci: $(BIN)fibonacci
	./$<

.PHONY: clean mrproper

clean:
	rm -f *.o *~ *#

mrproper:
	rm -f $(EXEC)